import http from '../index'

// 分页获取地址
export const getAddresses = ({ ascended = null, current = null, size = null, sortFieldName = null, addrType = null }) => {
    return http.get("user-address", { ascended, current, size, sortFieldName, addrType })
}

// 根据sid获取地址
export const getAddressDetail = ({ sid }) => {
    return http.get("user-address/" + sid)
}

// 新增地址
export const addAddress = ({ addrType, address, city, defaultAddr, district, districtCode, latitude, longitude, memberName, memberPhone, province, status = null }) => {
    return http.post("user-address", { addrType, address, city, defaultAddr, district, districtCode, latitude, longitude, memberName, memberPhone, province, status })
}

// 修改地址
export const editAddress = ({ sid, addrType, address, city, defaultAddr, district, districtCode, latitude, longitude, memberName, memberPhone, province, status = null }) => {
    return http.put("user-address/" + sid, { addrType, address, city, defaultAddr, district, districtCode, latitude, longitude, memberName, memberPhone, province, status })
}

// 批量删除地址
export const delAddresses = ({ sidList }) => {
    return http.put("user-address/delete", { sidList })
}

// 设为默认地址
export const setDefaultAddress = ({ sid }) => {
    return http.put("user-address/" + sid + '/default')
}